<?php
class DigUi_View_Helper_DigUiMessage extends Zend_View_Helper_Abstract 
{
    const CRITICAL = 0;
    const WARNING = 1;
    const INFO = 2;
    
    public function digUiMessage()
    {
        return $this;
    }
    
    public function addMessage($message, $status = self::INFO)
    {
        $classArray = array(
            self::CRITICAL	=> 'critical',
            self::WARNING     => 'warning',
            self::INFO        => 'info'
        );
        $message = '<span class="' . $classArray[$status] . '">' . $message . '</span>';
        if(is_array($this->view->messages)) {
            $this->view->messages[] = $message;
        } else {
            $this->view->messages = array($message);
        }
    }
    
    public function render()
    {
        $xhtml = array();
        if(is_array($this->view->messages) && count($this->view->messages) > 0) {
            return $this->view->htmlList($this->view->messages, false, array('class' => 'messages ui-widget-content ui-state-highlight ui-corner-all'), false);
        }
    }
}
?>